/*
 * @Author: szx
 * @Date: 2022-07-12 13:02:33
 * @LastEditTime: 2022-07-12 13:41:55
 * @Description:
 * @FilePath: \leetcode\1200-1299\1252\1252.js
 */
/**
 * @param {number} m
 * @param {number} n
 * @param {number[][]} indices
 * @return {number}
 */
var oddCells = function (m, n, indices) {
    const arr = new Array(m).fill(0).map(() => new Array(n).fill(0));
    for (let [r, c] of indices) {
        for (let j = 0; j < n; j++) arr[r][j]++;
        for (let i = 0; i < m; i++) arr[i][c]++;
    }
    let res = 0;
    for (let i of arr) {
        for (let j of i) {
            if (j & 1) res++;
        }
    }
    return res;
};

var oddCells = function (m, n, indices) {
    const rows = new Array(m).fill(0);
    const cols = new Array(n).fill(0);
    for (let [r, c] of indices) {
        rows[r]++;
        cols[c]++;
    }
    let res = 0;
    for (let i of rows) {
        for (let j of cols) {
            if ((i + j) & 1) res++;
        }
    }
    return res;
};
